#include <LLIIO/EXRImage.h>

EXRImage::EXRImage()
{
}

EXRImage::~EXRImage()
{
}

bool EXRImage::Open( const char * szPath )
{
    bool bRet = false ;

    m_pInputFile.reset(new Imf::InputFile( szPath ) ) ;
    if ( m_pInputFile )
    {
        if (m_pInputFile->isComplete())
        {
            bRet = true ;
        }
    }

    return bRet ;
}

int EXRImage::GetWidth() const
{
    int iRet = 0 ;

    if ( m_pInputFile )
    {
        iRet = m_pInputFile->header().dataWindow().size().x ;
    }
    else if ( m_pOutputFile )
    {
        iRet = m_pOutputFile->header().dataWindow().size().x ;
    }

    return iRet ;
}

int EXRImage::GetHeight() const
{
    int iRet = 0 ;

    if ( m_pInputFile )
    {
        iRet = m_pInputFile->header().dataWindow().size().y ;
    }
    else if ( m_pOutputFile )
    {
        iRet = m_pOutputFile->header().dataWindow().size().y ;
    }

    return iRet ;
}

void EXRImage::Close()
{
    m_pInputFile.reset() ;
    m_pOutputFile.reset() ;
}
